<?php

namespace App\Http\Requests;

use App\Http\Constants\ClosingRuleConstants;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class CoinsApplicationUpdateRuleRequest extends FormRequest
{
    use CommonRequest;
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rules = [
            'settle_rule_id' => [
                'required',
                Rule::in(array_column(ClosingRuleConstants::CLOSING_RULE,'value'))
            ],
        ];
        $rules = array_merge($rules,CoinsApplicationRequest::baseRules());

        return $rules;
    }


    public function messages()
    {
        $settle_rule_id_in_msg = implode('or',array_column(ClosingRuleConstants::CLOSING_RULE,'label'));
        $messages = [
            'settle_rule_id.required' => '结算规则,选项不能为空',
            'settle_rule_id.in' => '结算规则 选项只能是:'.$settle_rule_id_in_msg,
        ];
        $messages = array_merge($messages,CoinsApplicationRequest::baseMessages());

        return $messages;
    }
}
